<?php
/**
 * Created by PhpStorm.
 * User: sunzexin
 * Date: 2018/1/20
 * Time: 16:37
 */

namespace App\Http\Controllers\MiniProgramAdmin;


use App\Http\Traits\PartnerTrait;
use App\Http\Logics\MiniProgramAdmin\PartnerLogic;
use App\Http\Controllers\BaseController;
class PartnerController extends BaseController
{
    use PartnerTrait;
    /**
     * @SWG\Get(
     *     path="/partner/detail",
     *     tags={"Partner"},
     *     description="合作者详情",
     *     operationId="getPartnerDetail",
     *     produces={"application/json", "application/xml", "text/xml", "text/html"},
     *     @SWG\Parameter(
     *         name="loginSession",
     *         in="query",
     *         description="验证秘钥",
     *         required=true,
     *         type="string"
     *     ),
     *     @SWG\Parameter(
     *         name="partner_id",
     *         in="query",
     *         description="合作者ID",
     *         required=true,
     *         type="string"
     *     ),
     *     @SWG\Response(
     *         response=200,
     *         description="pet response"
     *     )
     * )
     */
    public function getPartnerDetail()
    {
        $partner_id = $this->partner_id;
        $data = [
            'partner_id' => $partner_id
        ];
        $response = PartnerLogic::getPartnerDetail($data);
        if ($response->code){
            return $this->response($response->code, $response->message);
        }
        return $this->response($response->code, $response->message, $response->data);
    }

    /**
     * @SWG\Post(
     *     path="/partner/update",
     *     tags={"Partner"},
     *     description="合作者信息更新",
     *     operationId="update",
     *     produces={"application/json", "application/xml", "text/xml", "text/html"},
     *     @SWG\Parameter(
     *         name="loginSession",
     *         in="query",
     *         description="验证秘钥",
     *         type="string"
     *     ),
     *     @SWG\Parameter(
     *         name="partner_id",
     *         in="query",
     *         description="合作者ID",
     *         type="integer",
     *         format="int32"
     *     ),
     *     @SWG\Parameter(
     *         name="name",
     *         in="query",
     *         description="合作者名称",
     *         type="string"
     *     ),
     *     @SWG\Parameter(
     *         name="logo",
     *         in="query",
     *         description="合作者LOGO",
     *         type="string"
     *     ),
     *     @SWG\Parameter(
     *         name="summary",
     *         in="query",
     *         description="合作者简介",
     *         type="string"
     *     ),
     *     @SWG\Parameter(
     *         name="gzh_name",
     *         in="query",
     *         description="合作者公众号名称",
     *         type="string"
     *     ),
     *     @SWG\Parameter(
     *         name="mobile",
     *         in="query",
     *         description="合作者联系方式",
     *         type="string"
     *     ),
     *     @SWG\Parameter(
     *         name="since",
     *         in="query",
     *         description="合作者创建时间",
     *         type="string"
     *     ),
     *     @SWG\Response(
     *         response=200,
     *         description="pet response"
     *     )
     * )
     */
    public function update()
    {
        $loginSession = $this->loginSession;
        $partner_id = $this->partner_id;
        $name = $this->name;
        $logo = $this->logo;
        $summary = $this->summary;
        $gzh_name = $this->gzh_name;
        $mobile = $this->mobile;
        $since = $this->since;
        $data = [
            'partner_id' => $partner_id,
            'name' => $name,
            'logo' => $logo,
            'summary' => $summary,
            'gzh_name' => $gzh_name,
            'mobile' => $mobile,
            'since' => $since,
            'loginSession' => $loginSession
        ];
        $response = PartnerLogic::update($data);
        if ($response->code){
            return $this->response($response->code, $response->message);
        }
        return $this->response($response->code, $response->message, $response->data);
    }

    /**
     * @SWG\Post(
     *     path="/partner/createVideo",
     *     tags={"Partner"},
     *     description="创建合作者视频",
     *     operationId="createPartnerVideo",
     *     produces={"application/json", "application/xml", "text/xml", "text/html"},
     *     @SWG\Parameter(
     *         name="loginSession",
     *         in="query",
     *         description="验证秘钥",
     *         required=true,
     *         type="string"
     *     ),
     *     @SWG\Parameter(
     *         name="partner_id",
     *         in="query",
     *         description="合作者ID",
     *         required=true,
     *         type="integer",
     *         format="int32"
     *     ),
     *     @SWG\Parameter(
     *         name="url",
     *         in="query",
     *         description="视频地址",
     *         required=true,
     *         type="string"
     *     ),
     *     @SWG\Response(
     *         response=200,
     *         description="pet response"
     *     )
     * )
     */
    public function createPartnerVideo()
    {
        $partner_id = $this->partner_id;
        $url = $this->url;
        $data = [
            'partner_id' => $partner_id,
            'url' => $url
        ];
        $response = PartnerLogic::createPartnerVideo($data);
        if ($response->code){
            return $this->response($response->code, $response->message);
        }
        return $this->response($response->code, $response->message, $response->data);
    }

    /**
     * @SWG\Get(
     *     path="/partner/getVideoList",
     *     tags={"Partner"},
     *     description="获取合作者视频",
     *     operationId="getPartnerVideoList",
     *     produces={"application/json", "application/xml", "text/xml", "text/html"},
     *     @SWG\Parameter(
     *         name="loginSession",
     *         in="query",
     *         description="验证秘钥",
     *         required=true,
     *         type="string"
     *     ),
     *     @SWG\Parameter(
     *         name="partner_id",
     *         in="query",
     *         description="合作者ID",
     *         required=true,
     *         type="integer",
     *         format="int32"
     *     ),
     *     @SWG\Response(
     *         response=200,
     *         description="pet response"
     *     )
     * )
     */
    public function getPartnerVideoList()
    {
        $partner_id = $this->partner_id;
        $data = [
            'partner_id' => $partner_id
        ];
        $response = PartnerLogic::getPartnerVideoList($data);
        if ($response->code){
            return $this->response($response->code, $response->message);
        }
        return $this->response($response->code, $response->message, $response->data);
    }

    /**
     * @SWG\Post(
     *     path="/partner/updateVideo",
     *     tags={"Partner"},
     *     description="更新合作者视频",
     *     operationId="updatePartnerVideo",
     *     produces={"application/json", "application/xml", "text/xml", "text/html"},
     *     @SWG\Parameter(
     *         name="loginSession",
     *         in="query",
     *         description="验证秘钥",
     *         required=true,
     *         type="string"
     *     ),
     *     @SWG\Parameter(
     *         name="video_id",
     *         in="query",
     *         description="视频ID",
     *         required=true,
     *         type="integer",
     *         format="int32"
     *     ),
     *     @SWG\Parameter(
     *         name="url",
     *         in="query",
     *         description="视频地址",
     *         required=true,
     *         type="string"
     *     ),
     *     @SWG\Response(
     *         response=200,
     *         description="pet response"
     *     )
     * )
     */
    public function updatePartnerVideo()
    {
        $video_id = $this->video_id;
        $url = $this->url;
        $data = [
            'video_id' => $video_id,
            'url' => $url
        ];
        $response = PartnerLogic::updatePartnerVideo($data);
        if ($response->code){
            return $this->response($response->code, $response->message);
        }
        return $this->response($response->code, $response->message, $response->data);
    }

    /**
     * @SWG\Post(
     *     path="/partner/deleteVideo",
     *     tags={"Partner"},
     *     description="删除合作者视频",
     *     operationId="deletePartnerVideo",
     *     produces={"application/json", "application/xml", "text/xml", "text/html"},
     *     @SWG\Parameter(
     *         name="loginSession",
     *         in="query",
     *         description="验证秘钥",
     *         required=true,
     *         type="string"
     *     ),
     *     @SWG\Parameter(
     *         name="video_id",
     *         in="query",
     *         description="视频ID",
     *         required=true,
     *         type="integer",
     *         format="int32"
     *     ),
     *     @SWG\Response(
     *         response=200,
     *         description="pet response"
     *     )
     * )
     */
    public function deletePartnerVideo()
    {
        $video_id = $this->video_id;
        $data = [
            'video_id' => $video_id
        ];
        $response = PartnerLogic::deletePartnerVideo($data);
        if ($response->code){
            return $this->response($response->code, $response->message);
        }
        return $this->response($response->code, $response->message, $response->data);
    }
}